﻿
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Sharp.Domain.PlatformBoundedContext.MessageModule.Aggregates;
using Sharp.Domain.PlatformBoundedContext.PersonModule.Aggregates;

namespace Sharp.Domain.PlatformBoundedContext.ModelConfigurations
{
    public partial class MessageBoxConfiguration
        : EntityTypeConfiguration<MessageBox>
    {
        public MessageBoxConfiguration()
        {
            HasKey(x => x.Id);

            Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();


            // Relationships
            HasRequired(t => t.Message)
                .WithMany(t => t.MessageBoxes)
                .HasForeignKey(d => d.MessageId);

            HasRequired(t => t.Sender)
                .WithMany(t => t.SendedMessages)
                .HasForeignKey(d => d.SenderId).WillCascadeOnDelete(false);
            HasRequired(t => t.Recipient)
                .WithMany(t => t.ReceivedMessages)
            .HasForeignKey(d => d.ReceiverId).WillCascadeOnDelete(false);

   
        }
    }
}